package ibm.cognos.imt.template

import groovy.xml.MarkupBuilder
import ibm.cognos.imt.CogReport

/**
 * Created with IntelliJ IDEA.
 * User: eric
 * Date: 5/8/14
 * Time: 5:32 PM
 * To change this template use File | Settings | File Templates.
 */
class ReportTemplate extends AbstractTemplate {
    CogReport report

    ReportTemplate(CogReport rpt){
         report = rpt
    }


    def generateTemplateSpec(MarkupBuilder b) {
        b.report(xmlns: "http://developer.cognos.com/schemas/report/7.0/", useStyleVersion: "10", expressionLocale: "en-us")
    }

    def getTemplateNode() {
        root = new XmlSlurper(false, false ).parseText(getSpecStr())
        root.appendNode(new ModelPathTemplate(report.modelPath).getTemplateNode())
        root.appendNode(new XmlSlurper(false, false).parseText("<drillBehavior modelBasedDrillThru=\"true\"/>"))
        root.appendNode(new QueriesTemplate(report.queryMap, report.filterList).getTemplateNode())
        root.appendNode(new LayoutsTemplate(report.elementMap).getTemplateNode())
        root.appendNode(new XmlAttributesTemplate().getTemplateNode())
        root
    }
}



